package net.toocruel.iqismart.web.Timer;

import net.toocruel.iqismart.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @Description
 * @Auther sty
 * @createTime 2018/5/14 下午6:29
 */
@Component
public class UpdateUserAdoptPercent {
    @Autowired
    private UserService userService;
//    @Scheduled(fixedRate = 1000 * 60 * 60 * 24L) //测试打开即可 项目启动时运行 然后以固定间隔运行
    @Scheduled(cron="0 18 0 * * ?")   //每天0点执行
    public void run(){
        userService.findAll().forEach(user -> userService.updateAdoptPercent(user.getId()));
    }
}
